package com.ruoyi.hotel.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.hotel.domain.HlBooking;
import com.ruoyi.hotel.service.IHlBookingService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 酒店预约Controller
 * 
 * @author ruoyi
 * @date 2022-12-10
 */
@RestController
@RequestMapping("/hotel/hlbooking")
public class HlBookingController extends BaseController
{
    @Autowired
    private IHlBookingService hlBookingService;


    /**
     * 查询酒店预约列表
     */
    @PreAuthorize("@ss.hasPermi('hotel:hlbooking:list')")
    @GetMapping("/list")
    public TableDataInfo list(HlBooking hlBooking)
    {
        startPage();
        List<HlBooking> list = hlBookingService.selectHlBookingList(hlBooking);
        return getDataTable(list);
    }

    /**
     * 导出酒店预约列表
     */
    @PreAuthorize("@ss.hasPermi('hotel:hlbooking:export')")
    @Log(title = "酒店预约", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HlBooking hlBooking)
    {
        List<HlBooking> list = hlBookingService.selectHlBookingList(hlBooking);
        ExcelUtil<HlBooking> util = new ExcelUtil<HlBooking>(HlBooking.class);
        util.exportExcel(response, list, "酒店预约数据");
    }

    /**
     * 获取酒店预约详细信息
     */
    @PreAuthorize("@ss.hasPermi('hotel:hlbooking:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(hlBookingService.selectHlBookingById(id));
    }

    /**
     * 新增酒店预约
     */
    @PreAuthorize("@ss.hasPermi('hotel:hlbooking:add')")
    @Log(title = "酒店预约", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HlBooking hlBooking)
    {
        return toAjax(hlBookingService.insertHlBooking(hlBooking));
    }

    /**
     * 修改酒店预约
     */
    @PreAuthorize("@ss.hasPermi('hotel:hlbooking:edit')")
    @Log(title = "酒店预约", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HlBooking hlBooking)
    {
        return toAjax(hlBookingService.updateHlBooking(hlBooking));
    }

    /**
     * 删除酒店预约
     */
    @PreAuthorize("@ss.hasPermi('hotel:hlbooking:remove')")
    @Log(title = "酒店预约", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(hlBookingService.deleteHlBookingByIds(ids));
    }
}
